import {RequestServerClass} from '../../util/request';
// 救援队伍
export class RescueTeamServer {

    public rSerivce: any;

    constructor(opt: any, axiosFilterFn?: any) {
        this.rSerivce = new RequestServerClass(opt);
    }

    public list() {
        const list = this.getDate();
        return new Promise((resolve, reject) => {
            resolve(list);
        });
    }

    public findByType(type: number) {
        const list = this.getDate();
        return new Promise((resolve, reject) => {
            const result: any = [];
            list.forEach((m: any) => {
                if (m.teamType === type) {
                    result.push(m);
                }
            });
            resolve(result);
        });
    }

    public save(data: any) {
        return new Promise((resolve, reject) => {
            resolve(null);
        });
    }

    private getDate() {
        const list: any = [];
        for (let i = 0; i < 10; i++) {
            list.push({
                teamid: `id${i}`,
                teamname: '救援队' + i,
                captain: '队长' + i,
                telephone: '1862795208' + i,
                chargeAreaz: '武昌区',
                areaflag: i % 3 === 0 ? 3 : i % 3,
                personnum: 35,
                surgery: 5,
                Medicine: 7,
                cdc: 3,
                nurse: 20,
                hospsource: '北京市人民医院' + i,
                longitude: 116 + 3 * Math.random(),
                latitude: 39 + 3 * Math.random(),
                lon: 114 + Math.random() * 0.02,
                lat: 30 + Math.random() * 0.02,
            });
        }
        return list;
    }
}
